home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / FuzAxon / BKGausFu.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  2.0 KB  |  59 lines

  1. // Dynamic link library implementation of NeuroSolutions BackAxon component
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /* Backpropagation of component */
  6.  
  7. __declspec(dllexport) void performBackFuzzyAxon(
  8.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  9.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *error,        // Pointer to the sensitivity vector
  14.     NSFloat    *param,     // Pointer to the layer of parameters for the MFs
  15.     int        paramIndex,    // Index of the MF parameter
  16.     int        winnerIndex,// Index of the winning MF
  17.     NSFloat winnerVal,    // Value of the winning Input
  18.     NSFloat *returnVal    // Return value
  19.     )
  20. {
  21.     NSFloat c = *(param + winnerIndex);
  22.     NSFloat sigma = *(param + winnerIndex + 1);
  23.     if (sigma == 0.0f)
  24.         *returnVal = 0.0f;
  25.     else {
  26.         NSFloat exp_fraction = (winnerVal - c) / sigma;
  27.         NSFloat exp_final = (NSFloat)((exp_fraction*exp_fraction) / -2.0);
  28.         NSFloat fwrd_activation = (NSFloat)exp (exp_final);
  29.         if (paramIndex == winnerIndex)
  30.         {
  31.             NSFloat deriv_fwrd = (NSFloat)((winnerVal - c) / (sigma*sigma));
  32.             *returnVal = fwrd_activation * deriv_fwrd;
  33.         }
  34.         if (paramIndex == (winnerIndex + 1)) {
  35.             NSFloat deriv_fwrd = (NSFloat)(pow ( (winnerVal - c), 2.0) / pow (sigma, 3.0));
  36.             *returnVal = fwrd_activation * deriv_fwrd;
  37.         }
  38.     }
  39. }
  40.  
  41. /******************************************/
  42. /* Management of instance data (OPTIONAL) */
  43. /*
  44. __declspec(dllexport) DLLData *allocBackFuzzyAxon(
  45.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  46.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  47.     int     rows,        // Number of rows of PEs in the layer
  48.     int     cols        // Number of columns of PEs in the layer
  49.     )
  50. {
  51.     DLLData *instance = allocDLLInstance(oldInstance);
  52.     return instance;
  53. }
  54.  
  55. __declspec(dllexport) void freeBackFuzzyAxon(DLLData *instance)
  56. {
  57.     freeDLLInstance(instance);
  58. }
  59. */